home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games 1996 July / Amiga Games 1996 #7.iso / rexx / playhifi.dopus5 < prev    next >
Text File  |  1996-01-14  |  9KB  |  315 lines

  1. /* Programm: PlayHifi.dopus5
  2. ** $VER: PlayHifi.dopus5 1.4 (20-Jan-96)
  3. ** 
  4. ** Needed: Directory Opus V5.xx (© by Jonathan Potter & GPSoftware)
  5. **         Play16 (© 1995 by Thomas Wenzel)
  6. **         mpega (© 1995 by Stephane Tavenard) or/and PeggyPlus MPEG-Card
  7. **         PlayADPCM (Autor Christian Buchner)
  8. **
  9. ** Copyright © 1995 Eckhard Ludwig (Eckhard@top.east.de)
  10. ** PlayHifi.dopus5 is copyrighted freeware. It may be distributed freely.
  11. **
  12. ** Call as:
  13. ** ------------------------------------------------------------------------------
  14. ** ARexx    DOpus5:ARexx/PlayHifi.dopus5 {Qp}
  15. ** ------------------------------------------------------------------------------
  16. ** Set all Attribut off.
  17. */
  18.  
  19. /*--------S E T T I N G S : -------------------------------------------*/
  20. /* If the file ENV:PlayHifi.PREFS exists, that one will override the   */
  21. /* settings here ...                                                   */
  22.  
  23. /*- Path to Player command --------------------------------------------*/
  24. Play16 = "C:Play16"
  25. PL16_OPTIONS=" Paula14 FILTER=OFF"
  26.  
  27. PlayADPCM = "C:PlayADPCM"
  28.  
  29. /*- Path to MPEGPlayer command ----------------------------------------*/
  30. PlayMPEG = "C:mpega"   /* Softwareplayer */
  31. MPEGA_OPTIONS=" -p -f0 -d2 -q2 "
  32. /*---------------------------------------------------------------------*/
  33.  
  34. Index  = 'T:PlayDOpus5Index.temp' /* Temporaere Titelliste */
  35. parse arg portname
  36. if portname='' then
  37.    portname='DOPUS.1'
  38. address value portname
  39.  
  40. options results
  41. options failat 21
  42. lf='0a'x
  43.  
  44. address command 'Delete >NIL: '||Index  /*falls Index in Benutzung, läuft Player bereits*/
  45.  
  46. if open(1,'env:PlayHifi.prefs','R') then do
  47.    do i=1 to 6
  48.     prefs.i = readln(1)
  49.         end
  50.    if prefs.2 ~="" then PLAY16=prefs.2
  51.    if prefs.3 ~="" then PlayADPCM=prefs.3
  52.    if prefs.4 ~="" then PlayMPEG=prefs.4
  53.    if prefs.5 ~="" then PL16_OPTIONS=prefs.5
  54.    if prefs.6 ~="" then MPEGA_OPTIONS=prefs.6
  55.    drop prefs.
  56.    call close(1)
  57.    end
  58.  
  59. if ~show('l','rexxsupport.library') then
  60.     call addlib('rexxsupport.library',0,-30,0)
  61.  
  62. /* init locale */
  63. if ~show(l,'locale.library') then
  64.         call addlib('locale.library',0,-30)
  65. if show(l,'locale.library') then
  66.         catalog=opencatalog('PlayHifi.catalog','english',0)
  67.  
  68. lister query source
  69. if rc>0 then do
  70.    dopus front
  71.    dopus request '"'getcatstr(0,'Error:'lf'No source selected')'"' getcatstr(1,'Quit')
  72.    exit
  73. end
  74.  
  75. parse var result handle 
  76.  
  77. lister query handle numselfiles
  78. if result=0 then do
  79.      dopus front
  80.      dopus request '"'getcatstr(2,'Error:'lf'No entry selected')'"' getcatstr(1,'Quit')
  81.      exit
  82. end
  83.  
  84. if exists(Index) then Index=Index||'1'
  85.    else Test2=1
  86.    
  87. if exists(Index) then call open('output',Index,'A')
  88.    else do
  89.       if open('output',Index,'w') ~=1 then do
  90.          dopus request '"'getcatstr(3,'Error:'lf'Load script in to editor and set path to Index !')'"' getcatstr(1,'Quit')
  91.          exit
  92.          end
  93.    end
  94.  
  95. lister set handle busy on
  96. lister query handle path
  97. QuellPfad=result
  98.  
  99. lister query handle selfiles stem files.
  100. lister set handle progress files.count getcatstr(4,'Scanning for Index...')
  101. lister refresh handle full  
  102.  
  103. do i=0 to files.count-1
  104.    lister query handle abort
  105.    if result then do
  106.     test=0
  107.     leave
  108.     end
  109.    lister set handle progress count i+1
  110.    lister set handle progress name files.i
  111.    Titel=Quellpfad||files.i
  112.    call DTTEST
  113.    if DT~=0 then do
  114.       lister query handle entry '"'files.i'"' stem fileinfo.
  115.       call writeln('output',Titel' @SIZE='fileinfo.size' @COMMENT='fileinfo.comment)
  116.       test=1
  117.       end
  118.    lister select handle '"'files.i'"' off
  119. end
  120. lister refresh handle full
  121. lister set handle busy off
  122. call close('output')
  123.  
  124. if Test2~=1 then do
  125.    if test=1 then do
  126.        dopus front 
  127.        dopus request '"'getcatstr(14,'Songs added to playlist')'"' 'OK'
  128.        end
  129.    exit
  130.    end
  131. if test ~=1 then do
  132.    address command 'Delete >NIL: '||Index
  133.    exit
  134.    end
  135.  
  136. lister new
  137. handle=result
  138. lister set handle title getcatstr(5,'Hifi Player')
  139. do forever
  140.  lister set handle sort date
  141.  call open('input2',Index,'R')
  142.  do i = 1 to 200
  143.    Zeile=readln('input2')
  144.    if Zeile="" then leave
  145.    SPOS=pos("@SIZE=",Zeile)
  146.    CPOS=pos("@COMMENT=",Zeile)
  147.    Titel=left(Zeile,SPOS-2)
  148.    if ~exists(Titel) then do
  149.      dopus front 
  150.      dopus request '"'getcatstr(8,'Error:'lf"'%s'"' not found !',Titel)'"' getcatstr(7,'Next')
  151.      iterate
  152.      end
  153.    call DTTEST
  154.    select
  155.     when DT="MP2" then MPEG=1
  156.     when DT="ADPCM2" then ADPCM=1
  157.     when DT="ADPCM3" then ADPCM=1
  158.     otherwise Play16DT=1
  159.    end
  160.    APOS=lastpos("/",Titel)
  161.    if APOS=0 then APOS=lastpos(":",Titel)   
  162.    songname=substr(Titel,APOS+1)
  163.    lister add handle '"'songname'" 'substr(Zeile,SPOS+6,CPOS-SPOS-6)' -1 'i' r 'substr(Zeile,CPOS+9)''
  164.    lister select handle '"'songname'"' on
  165.    lister set handle display name size comment
  166.  end
  167.  lister refresh handle full
  168.  call close ('input2')
  169.  
  170.  if MPEG=1 & ~show('P','Peggy') then do
  171.       if showlist("A","PEGGYPLUS")=1 then do
  172.         test=2
  173.     call pragma('STACK',8192)
  174.         address command 'RUN >NIL: <NIL: PEGGYPLUS:MPEGPlayer'
  175.         address command 'waitforport Peggy'
  176.         address value portname
  177.         dopus front
  178.         end
  179.       else do
  180.         if ~exists(PlayMPEG) then do
  181.           dopus front
  182.           dopus request '"'getcatstr(9,'Error:'lf'MPEG-Player not found !'lf'path to command: '"'%s'"'',PlayMPEG)'"' getcatstr(1,'Quit')
  183.       call Ende
  184.           end
  185.         end
  186.  end
  187.  if ADPCM=1 & ~exists(PlayADPCM) then do
  188.           dopus front
  189.           dopus request '"'getcatstr(10,'Error:'lf'ADPCM-Player not found !'lf'path to command: '"'%s'"'',PlayADPCM)'"' getcatstr(1,'Quit')
  190.       call Ende
  191.           end
  192.  if Play16DT=1 & ~exists(Play16) then do
  193.           dopus front
  194.           dopus request '"'getcatstr(11,'Error:'lf'Play16 not found !'lf'path to command: '"'%s'"'',Play16)'"' getcatstr(1,'Quit')
  195.       call Ende
  196.           end
  197.  
  198.  if open('input2',Index,'R') ~=1 then exit
  199.  lister set handle busy on
  200.  lister query handle selfiles stem files.
  201.  lister set handle progress files.count getcatstr(12,'Play sound ...')
  202.  lister refresh handle
  203.      
  204.  do i=0 to files.count-1
  205.    lister query handle abort
  206.    if result then leave
  207.    lister set handle progress count i+1
  208.    lister set handle progress name i+1"/"files.count"  "files.i
  209.    Zeile=readln('input2')
  210.    if Zeile="" then leave
  211.    Titel=left(Zeile,pos("@SIZE",Zeile)-2)
  212.    APOS=lastpos("/",Titel)
  213.    if APOS=0 then APOS=lastpos(":",Titel)   
  214.    songname=substr(Titel,APOS+1)
  215.    if songname ~=files.i then do
  216.     i=i-1
  217.     iterate
  218.     end
  219.    if ~exists(Titel) then do
  220.      dopus front 
  221.      dopus request '"'getcatstr(8,'Error:'lf"'%s'"' not found !',Titel)'"' getcatstr(7,'Next')
  222.      iterate
  223.      end
  224.    call DTTEST
  225.    select
  226.      when DT="MP2" then do
  227.          if show('P','Peggy') then do
  228.           address 'Peggy'
  229.           if MPEG=1 then do
  230.            open Titel
  231.            setwindow XOFF 0 YOFF 0 WIDTH 1 HEIGHT 1 XPIC 0 YPIC 0
  232.            Play
  233.            MPEG=2
  234.            end
  235.           else do
  236.            open Titel
  237.            Play async
  238.            Play wait
  239.            end
  240.        end
  241.        else address command PlayMPEG" "MPEGA_OPTIONS" " '"'Titel'"'
  242.      end
  243.    when DT="CDR" then address command Play16 '"'Titel'"' " RAW FREQ=44100 TRACKS=2 BITS=16 INTEL "PL16_OPTIONS
  244.    when DT="WAVE" then address command Play16 '"'Titel'"' " "PL16_OPTIONS
  245.    when DT="AIFF" then address command Play16 '"'Titel'"' " "PL16_OPTIONS
  246.    when DT="ADPCM2" then address command PlayADPCM '"'Titel'"' " NOFILTER"
  247.    when DT="ADPCM3" then address command PlayADPCM '"'Titel'"' " NOFILTER"
  248.    otherwise address command Play16 '"'Titel'"' " "PL16_OPTIONS
  249.    end
  250.    address value portname
  251.    lister select handle '"'files.i'"' off
  252.    lister refresh handle
  253.  end
  254.  call close ('input2')
  255.  lister clear handle
  256.  lister clear handle progress
  257.  lister refresh handle
  258.  if exists(Index||'1') then do
  259.         address command 'Delete >NIL: '||Index
  260.         address command 'rename from 'Index||"1"' to 'Index
  261.         iterate
  262.         end
  263.       else leave
  264. end
  265.  
  266. Ende:
  267. address value portname
  268. lister set handle title
  269. lister refresh handle full
  270. lister set handle busy off
  271. lister close handle
  272.  
  273. if show('P','Peggy') & test=2 then do
  274.    address 'Peggy'
  275.    QUIT
  276.    end
  277. address command 'Delete >NIL: '||Index
  278. exit
  279. /*--------------------------------------------------------------------------------*/
  280.  
  281. DTTEST: /*Auf zulässige Sounddatei testen*/
  282. dopus getfiletype '"'Titel'"' id
  283. DT=result
  284. select
  285.   when DT="MP2" then return
  286.   when DT="ADPCM2" then return
  287.   when DT="ADPCM3" then return
  288.   when DT="CDR" then return
  289.   when DT="WAVE" then return
  290.   when DT="VOC" then return
  291.   when DT="AU" then return
  292.   when DT="MAUD" then return
  293.   when DT="AIFF" then return
  294.   when DT="8SVX" then return
  295.   otherwise do
  296.      if DT='RESULT' then DT=getcatstr(13,'not identificed')
  297.      dopus front 
  298.       dopus request '"'getcatstr(6,'Error:'lf'The file '"'%s'"' is filetype '"'%s'"lf'Format not supported !',files.i,DT)'"' getcatstr(7,'Next')
  299.      DT=0
  300.      end
  301. end
  302. return DT
  303.  
  304. /*--------------------------------------------------------------------------------*/
  305. getcatstr:
  306.    parse arg msgno,msgstring,insert.1,insert.2
  307.    if catalog~=0 then msgstring=getcatalogstr(catalog,msgno,msgstring)
  308.    j=0
  309.    do while pos('%s',msgstring)>0
  310.       parse var msgstring fore '%s' aft
  311.       j=j+1
  312.       msgstring=fore||insert.j||aft
  313.       end
  314.    return msgstring
  315.